﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using DAO_DTO_WS.DAO;
using DAO_DTO_WS.DTO;

namespace LayoutTemplate
{
    public partial class XemChiTietSanPham : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            {
                if (IsPostBack == false)
                {
                    string maSanPham = Request.QueryString["masanpham"];
                    if (maSanPham.Equals(null))
                    {
                        Response.Redirect("DanhSachSanPham.aspx");
                    }
                    else
                    {
                        SanPhamDTO sp = new SanPhamDTO();
                        sp = SanPhamDAO.laySPTheoMa(int.Parse(maSanPham));
                        lbTenSanPham.Text = sp.ThongTin;
                        lbGiaBanDau.Text = sp.GiaGoc.ToString();
                        lbGiaBanGiam.Text = sp.GiaTietKiem.ToString();
                        lbMaSanPham.Text = maSanPham;
                        lbSoLuongToiDa.Text = sp.SoLuong.ToString();
                        lbSoLuongToiThieu.Text = sp.SoLuongToiThieu.ToString();
                        lbThongTinSanPham.Text = sp.ThongTin;

                        List<LoiBinhDTO> dsLoiBinh = LoiBinhDAO.LayCommentTheoSp(sp.MaSanPham);
                        int soLuong = dsLoiBinh.Count;
                        for (int i = 0; i < soLuong; ++i)
                        {
                            Response.Write("<div>" + dsLoiBinh[i].NoiDung + "</div>");
                        }
                    }
                }
            }
        }
    }
}
